#include<cstdio>
using namespace std;
int n,l,r,maxn;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	for(int i=l;i<=r;i++)
		{
			int t=i%n;
			if(maxn<t) maxn=t;
			if(maxn==n-1) break;
		}
	printf("%d",maxn);
	return 0;
} 
